<?php
	if(isset($_POST['model']))
	{
		$profileId=$_POST['model'];
		$_SESSION['profileid']=$profileId;
		$trackingcode=$_POST['series'];
		$_SESSION['trackingcode'] = $trackingcode;
	}
?>		
	
    <div class="row">
    <div class="entry" align="center">
      <form method="post" action="index.php" class="form-inline">
        
		<?php
						
							//$item = $accounts->getItems();
							if (isset($_SESSION['token'])) {
							
							if (count($accounts->getItems()) > 0) {
							echo'<select id="mark" name="mark" class="form-control">';
							foreach ($accounts->getItems() as $item) {
									echo"<option value='".$item['name']."'>".$item['name']."</option>";
							}
							echo'</select>';
							echo'<select id="series" name="series" class="form-control">';
							foreach ($accounts->getItems() as $item) {
								foreach($item->getWebProperties() as $wp) {
									echo"<option value='".$wp['id']."' class='".$item['name']."'>".$wp['name']."</option>";
								}
							}
							echo'</select>';
							echo'<select id="model" name="model" class="form-control">';
							foreach ($accounts->getItems() as $item) {

								foreach($item->getWebProperties() as $wp) {
									foreach($wp->getProfiles() as $view) {
									echo"<option value='".$view['id']."' class='".$wp['id']."'>".$view['name']."</option>";
									}
								}
							}
							
							
							echo'</select>';
							echo '<button class="btn btn-default" id="button" type="submit">Pilih Profile</button>';
							echo '</form>';
							}
							else {
							throw new Exception('No accounts found for this user.');
							}
							if (isset($_SESSION['profileid'])) {
							echo '<div class = "row" >';
							echo '<a href="index.php?objectives=exposure" class="btn btn-default" role="button">Exposure / Popularity </a>';
							echo '<a href="index.php?objectives=stickiness" class="btn btn-default" role="button">Stickiness / User Relationship</a>';
							echo '<a href="index.php?objectives=usefullness" class="btn btn-default" role="button">Usefullness</a>';
							echo '<a href="index.php?objectives=comarketingsuccess" class="btn btn-default" role="button">Comarketing Success</a>';
							echo '<a href="index.php?objectives=targeting" class="btn btn-default" role="button">Targeting Efficiency</a>';
							echo '</div>';	
							}
							}
							else {
							echo "
								<h2>Anda belum login</h2>";
							
							}
						?>
						
    						 
				

    </div>
  </div>
  
  <div align = "center">


</div>

  <script type="text/javascript" charset="utf-8">
  $(function() {

    /* For jquery.chained.js */
    $("#series").chained("#mark");
    $("#model").chained("#series");
    /* Show button after each pulldown has a value. */
    $("#model").bind("change", function(event) {
        if ("" != $("option:selected", this).val() && "" != $("option:selected", $("#model")).val()) {
            $("#button").fadeIn();
        } else {
            $("#button").hide();
        }
    });

  });
  </script>